<template>
    <div class="container">
        <Divider orientation="left">设定轮巡周期</Divider>
        <div v-for="(item,index) in loopList" :key="index">
            <Form :model="item" label-position="right">
                <Row :gutter="16">
                    <Col span="8">
                        <FormItem prop="lx_type" label="轮巡类型:">
                            <span v-if="item.lx_type == '1'">要件</span>
                            <span v-if="item.lx_type == '2'">条件</span>
                            <span v-if="item.lx_type == '3'">规则</span>
                            <span v-if="item.lx_type == '4'">数据</span>
                        </FormItem>
                    </Col>
                    <Col span="8">
                        <FormItem prop="lx_content" label="轮巡内容:">
                            {{item.lx_content}}
                        </FormItem>
                    </Col>
                    <Col span="8">
                        <FormItem class="required" prop="lx_zhou_qi" label="轮巡周期:">
                            {{item.lx_zhou_qi}}
                        </FormItem>
                    </Col>
                </Row>
                <br/>
                <br/>
            </Form>
        </div>
        <br/>
    </div>
</template>

<script>
import { select } from '@/api/setting'

export default {
  name: 'LoopDetail',
  data () {
    return {
      loopList: [],
      baseID: ''
    }
  },
  props: {
    nodeId: {
      type: String,
      default: () => {
        return ''
      }
    }
  },
  methods: {
    success (val) {
      val = this.$common.xeUtils.isEmpty(val) ? '操作成功' : val
      this.$Message.success(val)
    },
    error (data) {
      this.$Message.error({
        content: '操作失败,\n' + data.errmsg
      })
    },
    getInfoByID () {
      let param = { base_info_id: this.baseID }
      select('GovLoop', param).then(ret => {
        let data = ret.data
        if (data.errcode === 0) {
          data.data.forEach(item => {
            if (item.gov_flow_id === this.nodeId) {
              this.loopList.push(item)
            }
          })
        } else {
          this.error(data)
        }
      })
    }
  },
  mounted () {
    this.baseID = this.$route.query.id
    this.getInfoByID()
  }
}
</script>

<style scoped>
    .container {
        padding: 20px;
    }
</style>
